import os
from itertools import chain

from .json_helper import json_helper
from .dataset_tools import dataset_tools

class os_tools(dataset_tools):
    key = "OS"


    def get_wkt(self, sample) -> str:
        """
        image name to wkt
        
        Param
        -----
        sample the identifier of sample, e.g. path or point
        """
        fn = os.path.splitext(os.path.basename(sample))[0]
        fn = fn[3:]
        dir_ = os.path.dirname(sample)
        folder = os.path.basename(dir_)
        dir_ = os.path.dirname(dir_)
        size = os.path.basename(dir_)
        
        return str((size, folder, fn))


if __name__ == "__main__":
    # patch = "E:/datasets/OSdataset/256/train/opt2.png"
    # print(os_tools.get_wkt(None, patch))


    dt = os_tools("", "E:/workspace/SOMatch/json/os_dataset/256_train.json")
    print(f"{len(dt)} pairs loaded")


